home *** CD-ROM | disk | FTP | other *** search
/ Best of Shareware / Best of PC Windows Shareware 1.0 - Wayzata Technology (7111) (1993).iso / mac / DOS / UTILITY / MXMNU238 / NOVTRANS.MNU < prev    next >
Text File  |  1992-03-13  |  13KB  |  426 lines

  1. Comment
  2. ========================================================================
  3.  
  4. Novell menu to MarxMenu Translator:
  5.  
  6. Copyright 1989-92 by Marc Perkel * All rights reserved.
  7.  
  8. Usage: MARXMENU NOVTRANS <novell menu>
  9.  
  10. This program was written to translate Novell menus to MarxMenus. It is
  11. not an exact translation, but does the bulk of the work. It is up to you
  12. to edit the output file and tune the menu the way you want.
  13.  
  14. I have made no attempt to copy color information. I am not presenting
  15. selections in sorted order, but in the order in which they are defined.
  16.  
  17. The program creates a MarxMenu file names <menu>.TMP where <menu> is the
  18. name of your Novell menu file. Then it compiles <menu>.TMP into
  19. <menu>.MRX file that should be ready to run. if the menu needs to be
  20. altered, you will have to rename the <menu>.TMP file to a MNU file and
  21. then you can work with it like any other MarxMenu source file.
  22.  
  23. ========================================================================
  24. EndComment
  25.  
  26. Var
  27.    NovLines Menus Tmp MenuPtr ChoicePtr CommandPtr LinePtr
  28.    BoxDim X Y Z VarNum PromptLine Out Cap InputAVar NovellFileName
  29.    MarxMenuFileName NovellTempFileName Greek
  30.  
  31. ;----- Translator Messages
  32.  
  33. Const
  34.    TopMessage = "Joe Blow's Master Menu"
  35.    BottomMessage = "*-<< Acme Manufacturing Company >>-*"
  36.  
  37. ;----- If you want the Greek Column effect, set to true
  38.  
  39. Greek = False
  40.  
  41. Qualifier MenuName YPos XPos MenuColor MenuChoices
  42. Qualifier ChoiceName ChoiceCmd
  43.  
  44. Comment
  45. ========================================================================
  46.  
  47. This is the main body of the NovTrans Program.
  48.  
  49. ========================================================================
  50. EndComment
  51.  
  52. if not NetWorkVersion
  53.    ClearScreen
  54.    Writeln
  55.    Writeln 'This translator requires the network version of MarxMenu to Run!'
  56. endif
  57.  
  58. PreAmble
  59. PrepareFiles
  60. Header
  61. Parse
  62. WriteOutMenus
  63. Footer
  64.  
  65. ClearScreenFirst Off
  66. Writeln
  67. Execute 'MARXCOMP.EXE ' + MarxMenuFileName
  68.  
  69. Writeln
  70. Writeln 'To test your menu type MARX ' NovellFileName '. When you are satisfied with'
  71. Writeln 'the translation, replace the Novell ' NovellFileName '.MNU file'
  72. Writeln 'with the ' MarxMenuFileName ' file that NovTrans just created.'
  73.  
  74. Comment
  75. =====================================
  76.  
  77. Subroutine area.
  78.  
  79. =====================================
  80. EndComment
  81.  
  82. ;----- Initilize Variables and Environment
  83.  
  84. Procedure PreAmble
  85.   ClearScreenOnExit Off
  86.   StandardIO
  87.   Writeln
  88.   NovellFileName = UpperCase(ParamStr(2))
  89.   Usage
  90. EndProc
  91.  
  92. ;----- Proper Usage Procedure
  93.  
  94. Procedure Usage
  95.   if NovellFileName = ''
  96.     Writeln('Usage: MarxMenu NovTrans <menu>')
  97.     Writeln('Converts Novell menus to MarxMenus.')
  98.     Writeln('Be sure to backup your original menus before running!!')
  99.     ExitMenu
  100.   endif
  101. EndProc
  102.  
  103. ;----- Create FileNames and open Files
  104.  
  105. Procedure PrepareFiles
  106.   if pos('.',NovellFileName) > 0
  107.     NovellFileName = left(NovellFileName,pred(pos('.',NovellFileName)))
  108.   endif
  109.  
  110.   NovellTempFileName = NovellFileName + '.MNU'
  111.   MarxMenuFileName = ForceExtension(NovellTempFileName,'TMP')
  112.  
  113.   ReadTextFile NovellTempFileName NovLines
  114.   Writeln 'Creating ' MarxMenuFileName
  115.  
  116.   FileAssign(Out,MarxMenuFileName)
  117.   FileCreate(Out)
  118. EndProc
  119.  
  120.  
  121. Procedure BlankLine
  122.    FileWriteln(Out,'')
  123. EndProc
  124.  
  125. ;----- Write out the MarxMenu Source Header
  126.  
  127. Procedure Header
  128.   BlankLine
  129.   FileWriteln(Out,'Comment')
  130.   FileWriteln(Out,'==========================================================')
  131.   BlankLine
  132.   FileWriteln(Out,'This File was converted from Novell Menu: ',NovellTempFileName)
  133.   BlankLine
  134.   FileWriteln(Out,'It should behave in a similar way to the original menu but')
  135.   FileWriteln(Out,'not necessarilly exactly the same. It will be close enough')
  136.   FileWriteln(Out,'for you to fine tune it the way you want.')
  137.   BlankLine
  138.   FileWriteln(Out,'To add a choice to a menu simply use the AddChoice command')
  139.   FileWriteln(Out,'then add the appropiate Onkey statement.')
  140.   FileWriteln(Out,'The menu will make the size adjustments accordinaly.')
  141.   BlankLine
  142.   FileWriteln(Out,'  Example:')
  143.   FileWriteln(Out,'      AddChoice("Print Console",10)')
  144.   FileWriteln(Out,'      ... ')
  145.   FileWriteln(Out,'      ... ')
  146.   FileWriteln(Out,'      OnKey Task(10)')
  147.   FileWriteln(Out,'        PConsole')
  148.   FileWriteln(Out,'      ...')
  149.   BlankLine
  150.   FileWriteln(Out,"If you want to change the menu's center, pass the XY")
  151.   FileWriteln(Out,"coordinates to menu's CenterStretchBox procedure.")
  152.   BlankLine
  153.   FileWriteln(Out,'   Example:')
  154.   FileWriteln(Out,'      CenterStretchBox("Menu Header",10,10)')
  155.   BlankLine
  156.   FileWriteln(Out,'This will cause the menu to center at Col 10, Row 10')
  157.   BlankLine
  158.   FileWriteln(Out,'Once you are satisfied with the translation you can copy the TMP file')
  159.   FileWriteln(Out,'over the old Novell MNU file and just work with the MarxMenu version.')
  160.   BlankLine
  161.   FileWriteln(Out,'To control custom features, edit CUSTOM.INC and other INCLUDE Files.')
  162.   BlankLine
  163.   FileWriteln(Out,'=========================================================')
  164.   FileWriteln(Out,'EndComment')
  165.   BlankLine
  166.   FileWriteln(Out,';----- Create Variables')
  167.   BlankLine
  168.   FileWriteln(Out,'var')
  169.   FileWriteln(Out,'  %NovVar1')
  170.   FileWriteln(Out,'  %NovVar2')
  171.   FileWriteln(Out,'  %NovVar3')
  172.   FileWriteln(Out,'  %NovVar4')
  173.   FileWriteln(Out,'  %NovVar5')
  174.   FileWriteln(Out,'  %NovVar6')
  175.   FileWriteln(Out,'  %NovVar7')
  176.   FileWriteln(Out,'  %NovVar8')
  177.   FileWriteln(Out,'  %NovVar9')
  178.   FileWriteln(Out,'  %NovVar10')
  179.   FileWriteln(Out,'  KeepUsersInMenu')
  180.   BlankLine
  181.   BlankLine
  182.   FileWriteln(Out,';----- Here is where you add you own menu title and status line message')
  183.   BlankLine
  184.   FileWriteln(Out,'MenuTitle      = "',TopMessage,'"')
  185.   FileWriteln(Out,'StatusLineText = "',BottomMessage,'"')
  186.   BlankLine
  187.   FileWriteln(Out,';----- Load Novell look and feel routines')
  188.   BlankLine
  189.   FileWriteln(Out,'Include "CUSTOM.INC"')
  190.   if Greek then FileWriteln(Out,'Greek = True')
  191.   BlankLine
  192.   FileWriteln(Out,'KeepUsersInMenu Off')
  193.   BlankLine
  194.   FileWriteln(Out,'Comment')
  195.   FileWriteln(Out,'=================================')
  196.   BlankLine
  197.   FileWriteln(Out,'MarxMenu is capable of software metering. This means that it can')
  198.   FileWriteln(Out,'limit the number of users of an application to a fixed amount.')
  199.   BlankLine
  200.   FileWriteln(Out,'  OnKey Task (2)')
  201.   FileWriteln(Out,"     |if Limit('LOTUS',6) then Return ;limit Lotus to 6 Users")
  202.   FileWriteln(Out,'     CD \PUBLIC\LOTUS')
  203.   FileWriteln(Out,'     123')
  204.   BlankLine
  205.   FileWriteln(Out,'Read the METER.INC file for more details.')
  206.   BlankLine
  207.   FileWriteln(Out,'=================================')
  208.   FileWriteln(Out,'EndComment')
  209.   BlankLine
  210.   FileWriteln(Out,"Include 'METER.INC'  ;Software Metering")
  211.   BlankLine
  212.   FileWriteln(Out,'Comment')
  213.   FileWriteln(Out,'=================================')
  214.   BlankLine
  215.   FileWriteln(Out,'In order to add menu choices conditionally you would append the')
  216.   FileWriteln(Out,'choices to the end of the array after all the default choices')
  217.   FileWriteln(Out,'are set. For Example:')
  218.   BlankLine
  219.   FileWriteln(Out,'   if InGroup("ACCOUNTING")')
  220.   FileWriteln(Out,'      AddChoice("Payroll Menu",10)')
  221.   FileWriteln(Out,'   endif')
  222.   BlankLine
  223.   FileWriteln(Out,'Here is where menus are created.')
  224.   BlankLine
  225.   FileWriteln(Out,'=================================')
  226.   FileWriteln(Out,'EndComment')
  227.   BlankLine
  228.   FileFlush(Out);
  229. EndProc
  230.  
  231.  
  232. ;----- Write out the MarxMenu Source Footer
  233.  
  234. Procedure Footer
  235.    BlankLine
  236.    FileWriteln(Out,';----- End of Menu')
  237.    FileClose(Out)
  238. EndProc
  239.  
  240.  
  241. ;----- Delete all spaces in a string to make them a valid MarxMenu label
  242. ;      Returns a string
  243.  
  244. Procedure DeleteSpaces(St)
  245.    while Pos(' ',St) > 0
  246.       Delete(St,Pos(' ',St),1)
  247.    endwhile
  248.    while Pos('-',St) > 0
  249.       Delete(St,Pos('-',St),1)
  250.    endwhile
  251.    while Pos('.',St) > 0
  252.       Delete(St,Pos('.',St),1)
  253.    endwhile
  254.    while Pos('/',St) > 0
  255.       Delete(St,Pos('/',St),1)
  256.    endwhile
  257.    if (Mid(St,2,1) >= '0') and (Mid(St,2,1) <= '9')
  258.       Insert('X',St,2)
  259.    endif
  260.    Return St
  261. EndProc
  262.  
  263. ;----- Parse Novell Source into MenuName, MenuChoices, MenuCommands
  264. ;----- Returns a integer pointing to the end of the menu prompt
  265.  
  266. Procedure FindEndOfMenuPrompt(St)
  267. Var CommaPos Tail
  268.  
  269.   CommaPos = Pos(',',St)
  270.   if CommaPos = 0 Then Return Length(St) + 1
  271.   Tail = Mid(St,CommaPos + 1,255)
  272.   loop(Length(Tail))
  273.     if Pos(Mid(Tail,LoopIndex,1), '0123456789,') = 0
  274.       Writeln
  275.       Writeln('Error : There must not be any embedded commas in menu title!')
  276.       Writeln(St)
  277.       Writeln
  278.       ExitMenu
  279.     endif
  280.   endloop
  281.   Return CommaPos
  282. EndProc
  283.  
  284. ;----- Preprocess Lines
  285.  
  286. Procedure Parse
  287. Var TotalLines
  288.   TotalLines = NumberOfElements(NovLines)
  289.   Writeln('Parsing Novell Menu source code ...')
  290.   MenuPtr = 0
  291.   loop(TotalLines)
  292.      if (LoopIndex Mod 10 = 0) or (LoopIndex = TotalLines)
  293.        Write Cr
  294.        Write('Processing Line # ',LoopIndex,' of ',TotalLines)
  295.      endif
  296.      if left(NovLines[LoopIndex],1) = '%'
  297.         ChoicePtr = 0
  298.         CommandPtr = 0
  299.         MenuPtr = MenuPtr + 1
  300.         Tmp = mid(NovLines[LoopIndex],2,255)
  301.         X = FindEndOfMenuPrompt(Tmp)
  302.         Menus[MenuPtr].MenuName = ':' + left(Tmp,X - 1)
  303.         Tmp = mid(Tmp,X + 1,255)
  304.         Menus[MenuPtr].YPos = value(NextWord(Tmp))
  305.         Menus[MenuPtr].XPos = value(NextWord(Tmp))
  306.         Menus[MenuPtr].MenuColor = value(NextWord(Tmp))
  307.      else
  308.         if left(NovLines[LoopIndex],1) > ' '
  309.            CommandPtr = 0
  310.            ChoicePtr = ChoicePtr + 1
  311.            Trim(NovLines[LoopIndex])
  312.            if Mid(NovLines[LoopIndex], 2, 1) = '.'
  313.              Delete(NovLines[LoopIndex],1,2)
  314.              Trim(NovLines[LoopIndex])
  315.            endif
  316.            Menus[MenuPtr].MenuChoices[ChoicePtr].ChoiceName = NovLines[LoopIndex]
  317.         else
  318.            if ChoicePtr = 0
  319.               Writeln
  320.               Writeln 'Error in menu line: ' LoopIndex
  321.               ExitMenu
  322.            endif
  323.            CommandPtr = CommandPtr + 1
  324.            Menus[MenuPtr].MenuChoices[ChoicePtr].ChoiceCmd[CommandPtr] = NovLines[LoopIndex]
  325.         endif
  326.      endif
  327.   endloop
  328. EndProc
  329.  
  330. ;----- Create the Menu Choices Array
  331.  
  332. Procedure WriteOutMenuChoices
  333.   Writeln
  334.   Write('Translating: ' + mid(Menus[MenuPtr].MenuName,2,255) + ' ... ')
  335.   BlankLine
  336.   FileWriteln(Out,';----- Translating: ' + mid(Menus[MenuPtr].MenuName,2,255))
  337.   BlankLine
  338.   if MenuPtr > 1
  339.      Tmp = Menus[MenuPtr].MenuName
  340.      Tmp = DeleteSpaces(Tmp)
  341.      FileWriteln(Out,Tmp)
  342.      BlankLine
  343.   endif
  344.   loop(NumberOfElements(Menus[MenuPtr].MenuChoices))
  345.      FileWriteln(Out,'  AddChoice("' + Menus[MenuPtr].MenuChoices[LoopIndex].ChoiceName + '",' + Str(LoopIndex) + ')')
  346.   endloop
  347.   BlankLine
  348.   FileWriteln(Out,'CenterStretchBox("' + Mid(Menus[MenuPtr].MenuName,2,255) + '",' + Str(Menus[MenuPtr].XPos) + ',' + Str(Menus[MenuPtr].YPos) + ')')
  349.   BlankLine
  350. EndProc
  351.  
  352. ;----- Create the Onkey Statements
  353.  
  354. Procedure WriteOutOnkeyChoices
  355.   loop(NumberOfElements(Menus[MenuPtr].MenuChoices))
  356.     ChoicePtr = LoopIndex
  357.     Tmp = Menus[MenuPtr].MenuChoices[ChoicePtr].ChoiceName
  358.     FileWriteln(Out,'OnKey Task(' + Str(ChoicePtr) + ')')
  359.     loop(NumberOfElements(Menus[MenuPtr].MenuChoices[ChoicePtr].ChoiceCmd))
  360.       CommandPtr = LoopIndex
  361.       Tmp = Menus[MenuPtr].MenuChoices[ChoicePtr].ChoiceCmd[CommandPtr]
  362.       Trim(Tmp)
  363.       if UpperCase(Tmp) = '!LOGOUT' then Tmp = '|Logoff'
  364.       if Left(Tmp,1) = '%'
  365.         Tmp = DeleteSpaces(Tmp)
  366.         Tmp = '^' + Mid(Tmp,2,255)
  367.       endif
  368.       if (pos('@',Tmp) > 0) And (Pos('@ECHO',UpperCase(Tmp)) = 0)
  369.         X = 1
  370.         while X <= length(Tmp)
  371.           while (X <= length(Tmp)) and (mid(Tmp,X,1) <> '@')
  372.              X = X + 1
  373.           endwhile
  374.           Z[1] = mid(Tmp,X,1)
  375.           Z[2] = mid(Tmp,X + 1,1)
  376.           if (Z[1] = '@') and (((Z[2] > '0') and (Z[3] <= '9')) or (Z[2] = '"'))
  377.             if Z[2] = '"'
  378.               insert(' ',Tmp,X + 1)
  379.               VarNum = 10
  380.             else
  381.               VarNum = ord(Z[2]) - 48
  382.             endif
  383.             InputAVar = mid(Tmp,X + 2,1) = '"'
  384.             if InputAVar
  385.               Y = X + 3
  386.               while (mid(Tmp,Y,1) <> '"') and (Y <= length(Tmp))
  387.                 Y = Y + 1
  388.               endwhile
  389.               PromptLine = mid(Tmp,X + 3,Y - (X + 3))
  390.             else
  391.               Y = X + 1
  392.             endif
  393.           delete(Tmp,X,Y - X + 1)
  394.           insert('%NovVar' + Str(VarNum)  ,Tmp,X)
  395.           if InputAVar
  396.             FileWriteln(Out,'   |%NovVar',Str(VarNum), ' = ReadTextLine("' + PromptLine + '","",0,21)')
  397.           endif
  398.         endif
  399.       endwhile
  400.     endif
  401.       FileWriteln(Out,'   ' + Tmp)
  402.     endloop
  403.     BlankLine
  404.   endloop
  405. EndProc
  406.  
  407. ;----- Create the Menus
  408.  
  409. Procedure WriteOutMenus
  410. Var LoopCount
  411.   Writeln
  412.   LoopCount = MenuPtr
  413.   Loop LoopCount
  414.      MenuPtr = LoopIndex
  415.      WriteOutMenuChoices
  416.      WriteOutOnkeyChoices
  417.      if MenuPtr = 1
  418.         FileWriteln(Out,'OnKey ESC')
  419.         FileWriteln(Out,'   |if not KeepUsersInMenu or NovConsoleOperator')
  420.         FileWriteln(Out,'   |   LeaveMenu')
  421.         FileWriteln(Out,'   |endif')
  422.         BlankLine
  423.      endif
  424.   EndLoop
  425. EndProc
  426.